package com.example.block_chain.service.impl.major;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.block_chain.domain.pojo.Major;
import com.example.block_chain.mapper.MajorMapper;
import com.example.block_chain.service.major.MajorService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 专业表(Major)表服务实现类
 *
 * @author makejava
 * @since 2024-03-04 17:50:17
 */
@Service("majorService")
public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements MajorService {

    @Override
    public List<Major> getMajor(String schoolCode, String facultyCode) {
        LambdaQueryWrapper<Major> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(!schoolCode.isBlank(), Major::getSchoolCode, schoolCode)
                .eq(!facultyCode.isBlank(), Major::getFacultyCode, facultyCode);
        return list(queryWrapper);
    }

    @Override
    public Major getMajor(String majorCode) {
        LambdaQueryWrapper<Major> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Major::getMajorCode, majorCode);
        return getOne(queryWrapper);
    }
}
